//
//  NSString+Comparison.m
//  UIColor+Extention
//
//  Created by YiXuePxh on 16/2/2.
//  Copyright © 2016年 上海益学. All rights reserved.
//

#import "NSString+Comparison.h"

@implementation NSString (Comparison)
//判断手机号是否是正确的手机号码，1开头的十一位数字
+(BOOL)stringCheckPhoneNumberInput:(NSString* )_text{
    NSString* Regex = @"(1(3|5|7|8))\\d{9}$";
    NSPredicate* emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",Regex];
    return [emailTest evaluateWithObject:_text];
}
//判断密码是否是6-30位字母、数字或者下划线
+(BOOL)stringCheckPasswordInput:(NSString* )_text{
    //    if (_text.length>=6 && _text.length<=30) {
    //        return YES;
    //    }else{
    //        return NO;
    //    }
    NSString* Regex = @"[A-Z0-9a-z_]{6,30}";
    NSPredicate* emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",Regex];
    return [emailTest evaluateWithObject:_text];
}
//判读输入的是否是中文
+(BOOL)stringIsChineseCharater:(NSString* )_text{
    unichar c = [_text characterAtIndex:0];
    if (c >= 0x4E00 && c <= 0x9FA5) {
        return true;//中文
    }else{
        return false;//英文
    }
}
//判断输入的中文字符个数
+(NSInteger)chineseCountOfString:(NSString *)_text{
    int chineseCount = 0;
    if (_text.length > 0) {
        for (int i = 0; i < _text.length; i ++) {
            unichar c = [_text characterAtIndex:i];
            if (c >= 0x4E00 && c <= 0x9FA5) {
                chineseCount ++;//汉字个数
            }
        }
    }
    return chineseCount;
}
//判断字符串是否为空
+(BOOL) isBlankString:(NSString *)string {
    if (string == nil || string == NULL) {
        return YES;
    }
    if ([string isKindOfClass:[NSNull class]]) {
        return YES;
    }
    if ([[string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] length]==0) {
        return YES;
    }
    return NO;
}
+(BOOL)objectAndArrayPropertyIsNullAttribute:(id)attribute{
    if ((NSNull* )attribute == [NSNull null]) {
        return true;
    }
    return false;
}

@end
